import Vue from 'vue'
import configRouter from './config/router'
import {sync} from 'vuex-router-sync'
import store from './vuex/store'
import { loading } from "./vuex/actions/public"
import filters from './utils/filters'
import transition from './utils/transition'
import validators from './utils/validators'
import App from './components/App.vue'

import VueRouter from 'vue-router'
Vue.use(VueRouter);

import VueValidator from 'vue-validator'
Vue.use(VueValidator);

Vue.config.warnExpressionErrors = false;


// 装载过滤器
Object.keys(filters).forEach(k => Vue.filter(k, filters[k]));
// 装载过渡效果
Object.keys(transition).forEach(k => Vue.transition(k, transition[k]));
// 装载公用验证器
Object.keys(validators).forEach(k => Vue.validator(k, validators[k]));

const router = new VueRouter();
$(document)
    .ajaxStart(function () {
        loading(store, true);
    })
    .ajaxStop(function () {
        loading(store, false);
    });

configRouter(router);
sync(store, router);

// 启用路由
router.start(Vue.extend(App), '#root');
window.router = router;



